'''
Created on Jan 20, 2010

@author: madsk
'''

from PyQt4 import QtCore, QtGui

class Window(QtGui.QMainWindow):
    def __init__(self, app):
        super(Window, self).__init__()
        self._app = app
        self._fullscreen = False
        
    def setCentralWidget(self, widget):
        # If the widget has a setFullScreen method invoke it.
        if hasattr(widget, 'setFullScreen'):
            widget.setFullScreen(self._fullscreen)

        # Set the Qt central widget.
        super(Window, self).setCentralWidget(widget)

    def setFullScreen(self, fullscreen):
        self._fullscreen = fullscreen
        if self.centralWidget() and hasattr(self.centralWidget(), 'setFullScreen'):
            self.centralWidget().setFullScreen(self._fullscreen)
        self.show()
        
    def toggleFullScreen(self):
        self.setFullScreen(not self._fullscreen)
            
    def show(self):
        if self._fullscreen:
            super(Window, self).showFullScreen()
        else:
            super(Window, self).showNormal()
        